﻿<#-- 
 
 crea una extension para la clase para c# para la tabla  ${table}...
 basicamente para su uso como objectDataSource ...
 Author : Luis Molina...
 
 -->
<#-- variables used internally by the generator... -->
<#assign nameFile="${table}">
<#assign extensionFile="cs">
<#assign languageGenerated="c#">
<#assign description="c#">
<#assign targetDirectory="">
<#assign appliesToAllTables="true">
<#-- END variables used internally by the generator... -->
 
 

// using System.Collections.Generic;


 // devuelve un arraylist simple de ${table} 
        public static string getArray${table}AsString(String ${table.getKey()})
        {
            System.Data.SqlClient.SqlDataReader reg;
            string sql;
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            System.Collections.Generic.List<string> alist = new System.Collections.Generic.List<string>();

            try
            {
                sql = "select p.${table.getKey()} from ${table} p where p.${table.getKey()}=" + ${table.getKey()};
                reg = db.sql(sql);
                while (reg.Read())
                {
                    alist.Add(reg["${table.getKey()}"].ToString());
                }
                reg.Close();
            }
            catch (Exception ex)
            {

            }
            finally
            {
                db.Dispose();
            }
            //return the ArrayList as a delimited string
            return string.Join(",", alist.ToArray( ));
        }
 

 
 